package com.bc;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Vector;

import com.bc.custom.UserInfo;

public class BCServer {
	
	Socket clientSocket = null;
	ServerSocket serverSocket = null;
	PrintWriter out = null;
    BufferedReader in = null;
    BCProtocol bcp = new BCProtocol();

	
	public BCServer(){
		
	}
	
	public void init() throws IOException{
		
		serverSocket = null;
        try {
            serverSocket = new ServerSocket(4444);
        } catch (IOException e) {
            System.err.println("Could not listen on port: 4444.");
            System.exit(1);
        }

        clientSocket = null;
        try {
            clientSocket = serverSocket.accept();
        } catch (IOException e) {
            System.err.println("Accept failed.");
            System.exit(1);
        }

        out = new PrintWriter(clientSocket.getOutputStream(), true);
        in = new BufferedReader(
				new InputStreamReader(
				clientSocket.getInputStream()));
        
	}
	
	
	/**
	 * @param user the user requesting info
	 * @param k the lobby key
	 * @return
	 */
	public Vector<UserInfo> getLobbyUsersInfo(UserInfo user, String k){
		
		
		return null;
	}
	
	public void shutdown() throws IOException{
		out.close();
        in.close();
        clientSocket.close();
        serverSocket.close();
		
	}
	
}
